package com.atguigu.serviceedu.controller;


import com.atguigu.serviceedu.entity.EduVideo;
import com.atguigu.serviceedu.feign.AliyunVodFeignClient;
import com.atguigu.serviceedu.service.EduVideoService;
import com.atguigu.vo.ResultVO;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2023-08-05
 */
@RestController
@RequestMapping("/serviceedu/eduvideo")
@CrossOrigin
public class EduVideoController {
    @Autowired
    private EduVideoService eduVideoService;

    @PostMapping("/addVideo")
    public ResultVO addVideo(@RequestBody EduVideo eduVideo){
        boolean save = eduVideoService.save(eduVideo);
        if (save){
            return ResultVO.ok().Msg("添加视频成功").Data("flag",save);
        }else {
            return ResultVO.error().Msg("添加视频失败").Data("flag",save);
        }
    }
    @PutMapping("/editEduvideoById")
    public ResultVO editEduvideoById(@RequestBody EduVideo eduVideo){
        boolean b = eduVideoService.updateById(eduVideo);
        if (b){
            return ResultVO.ok().Msg("修改视频成功").Data("flag",b);
        }else {
            return ResultVO.error().Msg("修改视频失败").Data("flag",b);
        }
    }
    @DeleteMapping("/deleteVideoById/{id}")
    public ResultVO deleteVideoById(@PathVariable("id")String id){
        boolean b = eduVideoService.removeVideoById(id);
        if (b){
            return ResultVO.ok().Msg("删除视频成功").Data("flag",b);
        }else {
            return ResultVO.error().Msg("删除视频失败").Data("flag",b);
        }
    }

}

